<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
  body {
        width: 100vw;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #ecf0f1;
    }

    div {
        position: relative;
        width: 100px;
        height: 100px;
        cursor: pointer;
        /* border: 1px solid red; */
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
    }
    
    p{
      width: 50%;
      height: 50%;
      border-radius: 50%;
      background: #ccc;
      position: absolute;
      transition: all 1s;
    }
    /* div:hover p:nth-of-type(1){
      background: #e74c3c;
      transform: scale(3,3);
      opacity: 0;
    }
    div:hover p:nth-of-type(2){
      background: #e74c3c;
    } */
    .heart:nth-of-type(1){
      background: #e74c3c;
      transform: scale(3,3);
      opacity: 0;
    } 
    .heart:nth-of-type(2) {
      background: #e74c3c;
    }
</style>
<body>
  <div onclick="handleclick()">
    <p></p>
    <p></p>
</div>
</body>
<script>
    const pdom=document.querySelectorAll("p")
    function handleclick(){
      pdom.forEach(one=>{
        if(one.classList.contains("heart")){
          one.classList.remove("heart");
        }else{
          one.classList.add("heart");
        }
      })
    }
    
    
</script>
</html>
